#include <bits/stdc++.h>
using namespace std;
#define int long long
#define N 1000010
#define V 1000000
multiset <int> al,ar,bl[N],br[N];
struct stu
{
	int l,r,c;
};
stu p[N<<2];
void up(int x)
{
	p[x].l=max(p[x*2].l,p[x*2+1].l);
	p[x].r=min(p[x*2].r,p[x*2+1].r);
	p[x].c=min(p[x*2+1].r-p[x*2].l,min(p[x*2].c,p[x*2+1].c));
}
void build(int x,int l,int r)
{
	if(l==r)
	{
		p[x].l=-1e12;
		p[x].r=p[x].c=1e12;
		return;
	}
	int mid=(l+r)/2;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
	up(x);
}
void update(int x,int l,int r,int ql)
{
	if(r<ql||l>ql) return;
	if(l==r)
	{
		if(!bl[r].empty()) p[x].l=(*bl[r].rbegin());
		else p[x].l=-1e12;
		if(!br[l].empty()) p[x].r=(*br[l].begin());
		else p[x].r=1e12;
		p[x].c=p[x].r-p[x].l;
		return;
	}
	int mid=(l+r)/2;
	update(x*2,l,mid,ql);
	update(x*2+1,mid+1,r,ql);
	up(x);
}
signed main ()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	build(1,1,V);
	int tt;
	cin>>tt;
	while(tt--)
	{
		int l,r;
		char c;
		cin>>c>>l>>r;
		if(c=='A')
		{
			al.insert(l);
			ar.insert(r);
			br[l].insert(r);
			bl[r].insert(l);
		}
		else
		{
			al.erase(al.find(l));
			ar.erase(ar.find(r));
			br[l].erase(br[l].find(r));
			bl[r].erase(bl[r].find(l));
		}
		update(1,1,V,l);
		update(1,1,V,r);
		if((*al.rbegin())<(*ar.begin())) cout<<(*br[*al.rbegin()].begin())-(*bl[*ar.begin()].rbegin())<<endl;
		else cout<<p[1].c<<endl;
	}
	return 0;
}

